import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);
// login
// layout 布局页面
// Dashboard 仪表板页面 editor
// 订单管理 editor
// 用户管理 admin
// 角色管理 admin
export const routes = [
	{
		path: "/",
		redirect: "/login",
		hidden: true,
	},
	{
		path: "/login",
		component: () => import("../views/login"),
		hidden: true,
	},
];
export const syncRoutes = [
	{
		path: "/",
		component: () => import("../views/layout"),
		redirect: "/dashboard",
		children: [
			{
				path: "dashboard",
				component: () => import("../views/dashboard"),
				meta: {
					roles: ["editor", "admin"],
					icon: "el-icon-eleme",
					title: "仪表板",
				},
			},
		],
	},
	{
		path: "/",
		component: () => import("../views/layout"),
		redirect: "/order",
		children: [
			{
				path: "order",
				component: () => import("../views/OrderManagement"),
				meta: {
					roles: ["editor", "admin"],
					icon: "el-icon-eleme",
					title: "订单管理",
				},
			},
		],
	},
	{
		path: "/",
		component: () => import("../views/layout"),
		redirect: "/user",
		children: [
			{
				path: "user",
				component: () => import("../views/UserManagement"),
				meta: {
					roles: ["admin"],
					icon: "el-icon-eleme",
					title: "用户管理",
				},
			},
		],
	},
	{
		path: "/",
		component: () => import("../views/layout"),
		redirect: "/role",
		meta: {
			icon: "el-icon-eleme",
			title: "角色",
		},
		children: [
			{
				path: "role",
				component: () => import("../views/RoleManagement"),
				meta: {
					roles: ["admin"],
					icon: "el-icon-eleme",
					title: "角色管理",
				},
			},
			{
				path: "role2",
				component: () => import("../views/RoleManagement"),
				meta: {
					roles: ["admin"],
					icon: "el-icon-eleme",
					title: "角色管理2",
				},
			},
		],
	},
];

const router = new VueRouter({
	mode: "history",
	base: process.env.BASE_URL,
	routes,
});

export default router;
